﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Upload</title>
    <link rel="stylesheet" href="/layuimini-v2/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuimini-v2/css/public.css" media="all">
</head>
<body>
    <div class="layui-upload-drag" id="test10">
        <i class="layui-icon"></i>
        <p>点击上传，或将文件拖拽到此处</p>
        <div class="layui-hide" id="uploadDemoView">
            <hr>
            <img src="" alt="上传成功后渲染" style="max-width: 196px">
        </div>
    </div>
</body>
</html>
<script src="/layuimini-v2/lib/layui-v2.6.3/layui.js"></script>
<script>
    layui.use(['layer', 'form', 'upload'], function () {
        var layer = layui.layer,
            upload = layui.upload,
            form = layui.form,
            $ = layui.$;

        upload.render({
            elem: '#test10',
            url: '@Url.Action("upload")',
            accept: 'file',
            field: "stuInfo",     //后端利用request.files['stuInfo']来获取上传的文件
            exts: 'xls|xlsx|csv', //允许上传的类型
            size: '5*1024',

            before: function (obj) { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                index = layer.load(1); //上传loading //上传logo
            },
            done: function (res) {
                //layer.close(index)
                layer.msg('上传成功')
                layer.close(index);

                var iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.location.reload();
                parent.layer.close(iframeIndex);
            },
            error: function () {
                console.log('上传失败')
            }
        })
    });
</script>
